using System.Collections.Generic;
using FishFillets.Model;
using Microsoft.Xna.Framework;

namespace FishFillets.Data
{
    public class InitMap
    {
        private static readonly Map map = new Map {Levels = new List<LevelRef>()};

        public static Map Load()
        {
            // Fish House
            BranchAddNode("", "start", "script/start/init.lua", 320, 121);
            BranchAddNode("start", "briefcase", "script/briefcase/init.lua", 329, 153);
            BranchAddNode("briefcase", "cellar", "script/cellar/init.lua", 320, 189);
            BranchAddNode("cellar", "library", "script/library/init.lua", 301, 224);
            BranchAddNode("library", "stairs", "script/stairs/init.lua", 285, 252);
            BranchAddNode("stairs", "broom", "script/broom/init.lua", 279, 286);
            BranchAddNode("broom", "reef", "script/reef/init.lua", 292, 315);
            BranchAddNode("reef", "wc", "script/wc/init.lua", 314, 338);

            // Branch of New Generation
            BranchAddNode("broom", "hanoi", "script/hanoi/init.lua", 312, 266);
            BranchAddNode("hanoi", "rush", "script/rush/init.lua", 350, 265);
            BranchAddNode("rush", "fdto", "script/fdto/init.lua", 388, 264);
            BranchAddNode("fdto", "rotate", "script/rotate/init.lua", 424, 269);
            BranchAddNode("rotate", "nowall", "script/nowall/init.lua", 458, 275);
            BranchAddNode("nowall", "hole", "script/hole/init.lua", 490, 283);
            BranchAddNode("hole", "key", "script/key/init.lua", 525, 286);
            BranchAddNode("key", "keys", "script/keys/init.lua", 567, 297);
            BranchAddNode("keys", "linux", "script/linux/init.lua", 574, 267);

            // Ship Wrecks
            BranchAddNode("library", "submarine", "script/submarine/init.lua", 340, 228);
            BranchAddNode("submarine", "party1", "script/party1/init.lua", 381, 224);
            BranchAddNode("party1", "elk", "script/elk/init.lua", 422, 210);
            BranchAddNode("elk", "wreck", "script/wreck/init.lua", 456, 189);
            BranchAddNode("wreck", "viking1", "script/viking1/init.lua", 483, 158);
            BranchAddNode("viking1", "airplane", "script/airplane/init.lua", 491, 119);
            BranchAddNode("airplane", "bathyscaph", "script/bathyscaph/init.lua", 477, 84);
            BranchAddNode("bathyscaph", "tank", "script/tank/init.lua", 446, 58);
            BranchAddNode("tank", "viking2", "script/viking2/init.lua", 402, 61);
            BranchAddNode("viking2", "party2", "script/party2/init.lua", 372, 88);
            BranchAddNode("party2", "gods", "script/gods/init.lua", 391, 124);

            // Silver's Ship
            BranchAddNode("wreck", "cabin1", "script/cabin1/init.lua", 464, 227);
            BranchAddNode("cabin1", "snowman", "script/snowman/init.lua", 487, 252);
            BranchAddNode("snowman", "cannons", "script/cannons/init.lua", 521, 261);
            BranchAddNode("cannons", "kitchen", "script/kitchen/init.lua", 541, 232);
            BranchAddNode("kitchen", "cabin2", "script/cabin2/init.lua", 571, 210);
            BranchAddNode("cabin2", "captain", "script/captain/init.lua", 550, 175);
            BranchAddNode("captain", "map", "script/map/init.lua", 510, 199);

            // City In the Deep
            BranchAddNode("stairs", "elevator1", "script/elevator1/init.lua", 247, 234);
            BranchAddNode("elevator1", "city", "script/city/init.lua", 219, 217);
            BranchAddNode("city", "ufo", "script/ufo/init.lua", 192, 192);
            BranchAddNode("ufo", "columns", "script/columns/init.lua", 171, 161);
            BranchAddNode("columns", "pavement", "script/pavement/init.lua", 161, 125);
            BranchAddNode("pavement", "pyramid", "script/pyramid/init.lua", 175, 81);
            BranchAddNode("pyramid", "music", "script/music/init.lua", 207, 52);
            BranchAddNode("music", "crabshow", "script/crabshow/init.lua", 244, 44);
            BranchAddNode("crabshow", "elevator2", "script/elevator2/init.lua", 266, 77);
            BranchAddNode("elevator2", "atlantis", "script/atlantis/init.lua", 251, 115);

            // UFO
            BranchAddNode("ufo", "reactor", "script/reactor/init.lua", 167, 222);
            BranchAddNode("reactor", "magnet", "script/magnet/init.lua", 132, 238);
            BranchAddNode("magnet", "engine", "script/engine/init.lua", 95, 236);
            BranchAddNode("engine", "steel", "script/steel/init.lua", 70, 210);
            BranchAddNode("steel", "corridor", "script/corridor/init.lua", 78, 169);
            BranchAddNode("corridor", "experiments", "script/experiments/init.lua", 111, 159);
            BranchAddNode("experiments", "propulsion", "script/propulsion/init.lua", 118, 192);

            // UFO Exit
            BranchAddNode("reactor", "electromagnet", "script/electromagnet/init.lua", 198, 244);

            // Coral reef
            BranchAddNode("reef", "corals", "script/corals/init.lua", 325, 300);
            BranchAddNode("corals", "labyrinth", "script/labyrinth/init.lua", 359, 304);
            BranchAddNode("labyrinth", "imprisoned", "script/imprisoned/init.lua", 390, 330);
            BranchAddNode("imprisoned", "society", "script/society/init.lua", 409, 359);
            BranchAddNode("society", "creatures", "script/creatures/init.lua", 414, 387);
            BranchAddNode("creatures", "cancan", "script/cancan/init.lua", 390, 417);
            BranchAddNode("cancan", "pearls", "script/pearls/init.lua", 357, 404);
            BranchAddNode("pearls", "turtle", "script/turtle/init.lua", 343, 369);

            // Treasure Cave
            BranchAddNode("labyrinth", "aztec", "script/aztec/init.lua", 393, 298);
            BranchAddNode("aztec", "gems", "script/gems/init.lua", 425, 313);
            BranchAddNode("gems", "chest", "script/chest/init.lua", 445, 345);
            BranchAddNode("chest", "alibaba", "script/alibaba/init.lua", 475, 365);
            BranchAddNode("alibaba", "cave", "script/cave/init.lua", 510, 360);
            BranchAddNode("cave", "grail", "script/grail/init.lua", 539, 332);

            // Dump
            BranchAddNode("wc", "computer", "script/computer/init.lua", 289, 368);
            BranchAddNode("computer", "noground", "script/noground/init.lua", 257, 397);
            BranchAddNode("noground", "bathroom", "script/bathroom/init.lua", 217, 415);
            BranchAddNode("bathroom", "duckie", "script/duckie/init.lua", 170, 415);
            BranchAddNode("duckie", "puzzle", "script/puzzle/init.lua", 138, 385);
            BranchAddNode("puzzle", "dump", "script/dump/init.lua", 154, 342);
            BranchAddNode("dump", "barrel", "script/barrel/init.lua", 192, 351);

            // Secret Computer
            BranchAddNode("computer", "tetris", "script/tetris/init.lua", 254, 349);
            BranchAddNode("tetris", "emulator", "script/emulator/init.lua", 226, 317);
            BranchAddNode("emulator", "warcraft", "script/warcraft/init.lua", 198, 290);
            BranchAddNode("warcraft", "windoze", "script/windoze/init.lua", 162, 279);
            BranchAddNode("windoze", "hardware", "script/hardware/init.lua", 129, 290);
            BranchAddNode("hardware", "floppy", "script/floppy/init.lua", 97, 314);


            // branch_setEnding(codename, datafile, poster="");
            // Ending
            /*branch_setEnding("ending", "script/ending/init.lua",
                "script/ending/demo_poster.lua");*/


            // -----------------------------------------------------------------
            //file_include("script/worlddesc.lua");
            //file_include("script/worldfame.lua");
            return map;
        }

        private static void BranchAddNode(string parent, string name, string datafile, int x, int y)
        {
            LevelRef lr = new LevelRef
            {
                Name = name,
                Parent = parent,
                Position = new Point(x, y),
            };
            map.Levels.Add(lr);
        }
    }
}
